<template>
  <div class="page">
    <div class="header bg">
      <span class="title">项目码上智办</span>
      <div class="bigger" @click="routerJump('/home',1)"><img src="../../assets/home/icon15.png" />普通版</div>
    </div>
    <div class="content">
      <van-pull-refresh v-model="refreshLoading" @refresh="onRefresh">
        <div class="banner">
          <div class="banner-img">
            <van-swipe class="my-swipe" style="height: 100%" :autoplay="3000" indicator-color="white">
              <van-swipe-item v-for="item in swiperList" :key="item.id">
                <img :src="item.img" alt="" @click="linkto(item.link)">
              </van-swipe-item>
            </van-swipe>
          </div>
          <div class="bar-list f-r a-c j-b">
            <div class="bar-item f-c j-c a-c" @click="routerJump('/consulting-elder')">
              <img src="@/assets/home/icon1.png" alt="">
              <div class="bar-name">我要咨询</div>
            </div>
            <div class="bar-item f-c j-c a-c" @click="routerJump('/news-elder')">
              <img src="@/assets/home/icon2.png" alt="">
              <div class="bar-name">报批指导</div>
            </div>
            <div class="bar-item f-c j-c a-c" @click="routerJump('/data-package-elder')">
              <img src="@/assets/home/icon3.png" alt="">
              <div class="bar-name">数据礼包</div>
            </div>
            <div class="bar-item f-c j-c a-c" @click="routerJump('/out-problem-elder')">
              <img src="@/assets/home/icon4.png" alt="">
              <div class="bar-name">纾困解难</div>
            </div>
          </div>

        </div>
        <div class="process-list">
          <van-swipe class="my-swipe" style="height: 100%" :autoplay="3000" indicator-color="white">
            <van-swipe-item v-for="item in projectList" :key="item.id">
              <div class="process-item" @click="toProjectDetail(item)">
                <div class="name">
                  {{ item.projectName }}
                </div>
                <div class="desc f-r a-c">
                  <div class="icon-box">
                    <img src="@/assets/home/icon5.png" alt="">
                  </div>
                  <div class="text">
                    {{ processStatus[item.progress ] }}
                  </div>
                </div>
                <div>
                  <div class="button-show">{{ project_status[item.stage] }}</div>
                </div>
              </div>
            </van-swipe-item>
          </van-swipe>
        </div>
        <div class="header-title">特色服务</div>
        <div class="icon-list f-r f-w j-b">
          <div class="icon-item icon-item1 f-r a-c j-b" @click="routerJump('/call-elder')">
            <div class="name">外线联报</div>
            <div class="icon-box f-r a-c j-c">
              <img src="@/assets/home/icon6.png" alt="">
            </div>
          </div>
          <div class="icon-item icon-item2 f-r a-c j-b" @click="routerJump('/mediation-home-elder')">
            <div class="name">掌上中介</div>
            <div class="icon-box f-r a-c j-c">
              <img src="@/assets/home/icon7.png" alt="">
            </div>
          </div>
          <div class="icon-item icon-item3 f-r a-c j-b" @click="routerJump('/space-elder')">
            <div class="name">助企空间</div>
            <div class="icon-box f-r a-c j-c">
              <img src="@/assets/home/icon8.png" alt="">
            </div>
          </div>
          <div class="icon-item icon-item4 f-r a-c j-b" @click="routerJump('/space2-elder')">
            <div class="name">一键上门帮办</div>
            <div class="icon-box f-r a-c j-c" style="width: 65px;">
              <img src="@/assets/home/icon9.png" alt="">
            </div>
          </div>
        </div>
        <div class="header-title" style="margin-bottom: 0">帮办风采</div>
        <van-empty v-if="!tableData.length" description="暂无数据" />
        <div class="new-list">
          <div v-for="item in tableData" class="new-item f-r j-b" @click="toHelpDetail(item)">
            <div class="left f-c j-b">
              <div class="new-name">{{ item.title }}</div>
              <div class="date f-r a-c" style="justify-content: inherit;">
                {{ item.source }}<div>{{ item.data }}</div>
              </div>
            </div>
            <img class="img" :src="item.file">
          </div>
        </div>
        <div class="phone" @click="phoneCall()">
          <span>本服务由宁波市镇海区政务服务办公室提供服务咨询热线：</span><span class="blue">86563810</span>
        </div>
      </van-pull-refresh>
    </div>
    <TabBar url="/home" />
  </div>
</template>

<script>
import refresh from '@/mixins/refresh'
import { http_help, http_home, http_project } from '@/api'
import { Toast } from 'vant'
import { processStatus, project_status } from '@/dict'

export default {
  name: 'Home',
  mixins: [refresh],
  data() {
    return {
      swiperList: [],
      projectList: [],
      processStatus: processStatus,
      project_status: project_status
    }
  },
  created() {
    http_home.swiper().then(res => {
      this.swiperList = res.data.records
    })
    http_project.page().then(res => {
      console.log(res)
      this.projectList = res.data
    })
    // this.ticketpop()
  },
  methods: {
    // async  ticketpop() {
    //   if (ZWJSBridge.ssoTicket) {
    //     const ssoFlag = await ZWJSBridge.ssoTicket({})
    //     if (ssoFlag && ssoFlag.result === true) {
    //       // 使用 IRS“浙里办”统一单点登录组件
    //       if (ssoFlag.ticketId) {
    //         // TODO 应用方服务端单点登录接口
    //         http_home.login({tickId:ssoFlag.ticketId}).then(res => {
    //           ZWJSBridge.setLocalStorage({
    //             key: 'token',
    //             value: res.token
    //             })
    //             ZWJSBridge.setLocalStorage({
    //             key: 'userInfo',
    //             value: res
    //             })
    //         })
    //       }
    //     } else {
    //       // 异常情况：当前环境不支持 “浙里办”统一单点登录
    //     }
    //   } else {
    //     // 异常情况：ZWJSBridge 加载异常
    //   }
    // },
    callphone() {
      ZWJSBridge.phoneCall({
        corpId: '86563810'
      }).then((result) => {
        console.log('#### ZWJSBridge.phoneCall() log. ####')
        console.log(result);
      }).catch((error) => {
        console.log('#### ZWJSBridge.phoneCall() error. ####')
        console.log(error);
      });
    },
    linkto(url) {
      if (url !== '' && url !== null) {
        window.location.replace(url)
      }
    },
    toHelpDetail(item) {
      this.$router.push({
        path: '/help-handle-detail-elder',
        query: {
          id: item.id,
          vconsole: true
        }
      })
    },
    toProjectDetail(item) {
      this.$router.push({
        path: '/project-detail-elder',
        query: {
          userId: item.userId,
          id: item.id,
          projectId: item.projectId,
          vconsole: true
        }
      })
    },
    getList() {
      if (this.pageNo > 1 && this.tableData.length >= this.totalSize) return Toast('没有更多了')
      http_help.page({
        pageNo: this.pageNo,
        pageSize: this.pageSize
      }).then(res => {
        if (this.pageNo === 1) {
          this.tableData = res.data.records.map(el => {
            return {
              ...el
            }
          })
        } else {
          this.tableData = [
            ...this.tableData,
            ...res.data.records.map(el => {
              return {
                ...el
              }
            })
          ]
        }
        this.totalSize = res.data.total
        this.refreshLoading = false
      })
    }
  }
}
</script>

  <style scoped lang="scss">
  .phone{
  font-size: 16px;
  color: #808da1;
  font-weight: 400;
  line-height: 24px;
  text-align: center;
  // height: 37px;
  padding: 10px;
  .blue{
    color: #1492ff;
  }
}
  .page {
      background-color: #F3F3F3;
      width: 100vw;
      padding-top: 60px;
      position: relative;
      .header-title {
          margin-bottom: 15px;
          font-size: 24px;
          font-family: PingFang SC;
          font-weight: bold;
          color: #333333;
      }
      .content {
          position: relative;
          z-index: 2;
          padding: 0 12px;
          padding-bottom: 70px;
          .banner {
              background-color: #fff;
              border-radius: 10px;
              overflow: hidden;
              .banner-img {
                  width: 100%;
                  height: 160px;
                  img {
                      width: 100%;
                      height: 100%;
                  }
              }
          }
          .bar-list {
              padding: 18px 22px;
              .bar-item {
                //   width: 52px;
                  img {
                      width: 44px;
                      height: 44px;
                      margin-bottom: 7px;
                  }
                  .bar-name {
                      font-size: 16px;
                      line-height: 17px;
                      font-family: PingFang SC;
                      font-weight: 500;
                      color: #333333;
                  }
              }
          }
          .process-list {
              margin-top: 23px;
              margin-bottom: 30px;
              .process-item {
                  width: 100%;
                  // height: 127px;
                  background: #EFF5FF;
                  border: 1px solid #2F75FD;
                  border-radius: 20px;
                  padding: 13px 20px;
                  .name {
                      font-size: 24px;
                      font-family: PingFang SC;
                      font-weight: 500;
                      color: #333333;
                      margin-bottom: 10px;
                  }
                  .desc {
                      margin-bottom: 12px;
                      .icon-box {
                          width: 22px;
                          height: 22px;
                          background: #2B80FF;
                          border-radius: 50%;
                          line-height: 22px;
                          text-align: center;
                          margin-right: 7px;
                          img {
                             width: 11px;
                            height: 11px;
                          }
                      }
                      .text {
                          font-size: 16px;
                          font-family: PingFang SC;
                          font-weight: 500;
                          color: #999999;
                      }
                  }
                  .button-show {
                      width: 167px;
                      height: 28px;
                      line-height: 22px;
                      background: #C3DDFF;
                      border: 1px solid #2B80FF;
                      border-radius: 24px;
                      font-size: 16px;
                      font-family: PingFang SC;
                      font-weight: 500;
                      color: #2B87FC;
                      text-align: center;
                  }
              }
          }
          .icon-list {
              margin-bottom: 30px;
              .icon-item {
                  width: calc(50% - 4px);
                  height: 73px;
                  margin-bottom: 8px;
                  border-radius: 10px;
                  padding: 0 18px;
                  .name {
                      font-size: 20px;
                      font-family: PingFang SC;
                      font-weight: bold;
                      color: #FFFFFF;
                      line-height: 31px;
                  }
              }
              .icon-item1 {
                  background: linear-gradient(270deg, #8FC3F5, #8EBFF7);
              }
              .icon-item2 {
                  background: linear-gradient(270deg, #7DE1C6, #5CC6AF);
              }
              .icon-item3 {
                  background: linear-gradient(270deg, #FAC855, #FADC7C);
              }
              .icon-item4 {
                  background: linear-gradient(270deg, #F2958E, #F2998A);
              }
              .icon-box {
                  width: 51px;
                  height: 51px;
                  background: #FFFFFF;
                  border-radius: 50%;
                  img {
                      width: 31px;
                      height: 31px;
                  }
              }
          }
          .nav-title {
              font-size: 34px;
              line-height: 34px;
              font-family: PingFang SC;
              font-weight: bold;
              color: #333333;
          }
      }
      .header {
          z-index: 1;
          position: absolute;
          left: 0;
          top: 0;
          margin-top: -30px;
          padding-top: 47px;
          width: 100%;
          height:200px;
          background-image: url('~@/assets/home/header-bg.png');
          .title {
              display: inline-block;
              width: 100%;
              text-align: center;
              font-size: 22px;
              line-height: 42px;
              font-family: PingFang SC;
              font-weight: 500;
              color: #FFFFFF;
          }
      }
      .new-list {
          .new-item {
            box-sizing: content-box;
            //   height: 160px;
              padding: 14px 0;
              border-bottom: 1px solid #D2D2D2;
              .img {
                flex-shrink: 0;
                  width: 102px;
                  height: 75px;
                  font-size: 20px;
                  font-family: PingFang SC;
                  font-weight: bold;
                  color: #999999;
                  margin-left: 6px;
                  border: 1px solid #D2D2D2 ;
              }
              .left {
                  .new-name {
                      font-size: 16px;
                      font-family: PingFang SC;
                      font-weight: bold;
                      color: #666666;
                      line-height: 18px;
                  }
                  .desc {
                      font-size: 14px;
                      font-family: PingFang SC;
                      font-weight: bold;
                      color: #999999;
                      margin-top: 8px;
                      margin-bottom: 8px;
                  }
                  .date {
                      font-size: 14px;
                      font-family: PingFang SC;
                      font-weight: bold;
                      color: #999999;
                    padding-top: 10px;
                  }
                  .time {
                      margin-left: 12px;
                      font-size: 10px;
                      font-family: PingFang SC;
                      font-weight: bold;
                      color: #999999;
                  }
              }
          }
      }
  }
  .bigger{
    img{
        width: 14px;
        height: 14px;
        margin: 0 3px 0 7px;
    }
        width: 72px;
        height: 21px;
        border: 1px solid #FFFFFF;
        border-radius: 11px;
        line-height: 21px;
        font-size: 12.5px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #FFFFFF;
        float: right;
        position: absolute;
        top: 64px;
        right: 14px;
}
.tabbar{
    height: 65px !important;
    img{
      height: 20px !important;
      width: 20px !important;
    }
    .tabbarname{
      font-size: 16px !important;
    }
  }

  </style>
